# makefile
#  build with git revision number
#  example:  gb build -ldflags "-X main.build=`git rev-parse HEAD`" cmd/xxx

# varible
CMD = curd-gen
CURRENT_REVISION = `git rev-parse HEAD`

BIN_CMD = ./${CMD}

# target
all: cmd

# binary
win:
	@echo "[begin] release ==================="
	GOOS=windows GOARCH=amd64 go build -o ${CMD}-windows-amd64.exe
	@echo "[end]   release ==================="

nix:
	@echo "[begin] release ==================="
	GOOS=linux GOARCH=amd64 go build -o ${CMD}-linux-amd64
	@echo "[end]   release ==================="

mac:
	@echo "[begin] release ==================="
	GOOS=darwin GOARCH=amd64 go build -o ${CMD}-darwin-amd64
	@echo "[end]   release ==================="

.PHONY: clean
clean:
	rm -f ${BIN_CMD}
	rm -f ${CMD}-darwin-amd64
	rm -f ${CMD}-windows-amd64.exe
	rm -f ${CMD}-linux-amd64

help:
	@echo "make [option]: "
	@echo "\t all     : compile for all binaries"
	@echo "\t win     : generate compiled binary(windows)"
	@echo "\t nix     : generate compiled binary(linux)"
	@echo "\t mac     : generate compiled binary(osx)"
	@echo "\t clean   : clean files which are generated by compile"
	@echo "\t help    : print this help info"
	@echo "\n"
	@echo "make == make all"
